import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

import scau.cn.OpenedFileTable;
import scau.cn.OpenedFileTableItem;
import scau.cn.component.abstracts.Disk;
import scau.cn.component.domain.Catalog;
import scau.cn.component.domain.FileN;
import scau.cn.component.util.CatalogOp;
import scau.cn.component.util.FileOp;
import scau.cn.fat.FAT;

public class test {
	public static void main(String[] args) throws Exception {
		CatalogOp co = new CatalogOp();
		FAT fat = new FAT();
		Catalog root = new Catalog("C02", ".c", (byte) 0b00001100, fat, null);
		FileOp fo = new FileOp();
		File file = new File(root.findPath());
		file.mkdir();
		FileN f = fo.createFile("F01", (byte)0b00000100, root);
		System.out.println(file.getAbsolutePath());
		System.out.println(fo.openFile("F01", 1, root));
		System.out.println(f.getOpType());
		fo.writeFile("F01", root, "111111111111111111111111111111111111111111123123123123123123123123123123123123123123123123123123123123123123123123");
		System.out.println(root.getFileFromComponent("F01").getLength());
		System.out.println(fo.readFile("F01", root));
		fo.closeFile("F01", root);
		System.out.println(root.getComponent().size());
		Catalog C03 = co.createCatalog("C03", (byte)0b00001100, root);
		Catalog C04 = co.createCatalog("C04", (byte)0b00001100, C03);
		Catalog C05 = co.createCatalog("C05", (byte)0b00001100, C04);
		fo.createFile("F02", (byte)0b00000100, C04);
		fo.createFile("F03", (byte)0b00000100, C05);
//		//这里好像有时能删除，有时不能删除
//		//co.deleteCatalog(C03);
		File file1 = new File("conf.txt");
		file1.createNewFile();
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file1));
		oos.writeObject(root);
		
	}
}
